package com.zzxy.spring5.aspect;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspectJ {
    @Pointcut("execution(* com.zzxy.spring5.service..*Impl.*(..))")
    public void mypointCut(){

    }
    @Before("mypointCut()")
    public void myBefore(JoinPoint jp){
        //System.out.println(jp.getSignature().getName());
        System.out.println("my before ...");
    }
    @After("mypointCut()")
    public  void  myAfter(JoinPoint jp){
      //  System.out.println(jp.getSignature().getName());
        System.out.println("my after ...");
    }
    @AfterReturning (value = "mypointCut()",returning ="ret")
    public  void  myAfterReturing(JoinPoint jp,Object ret){
       // System.out.println(jp.getSignature().getName());
        System.out.println("my after returning ..." +ret);
    }
    @AfterThrowing(value = "mypointCut()",throwing ="e")
    public  void  myThrowing (JoinPoint jp, Throwable e){
       // System.out.println(jp.getSignature().getName());
        System.out.println("my throwing ..."+ e.getMessage());
    }
    @Around("mypointCut()")
    public Object myAround(ProceedingJoinPoint pjp) throws Throwable {

        System.out.println("my around before...");
        Object obj= pjp.proceed();
        System.out.println("my around after...");
        return obj;
    }
}
